package com.rdxer.service;

import com.rdxer.core.utils.IdWorker;
import com.rdxer.model.Question;
import com.rdxer.model.QuestionOption;
import com.rdxer.repository.QuestionOptionRepository;
import com.rdxer.repository.QuestionRepository;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Department 服务层
 */
@Service
@Data
@Getter
public class QuestionOptionService implements CRUDPageServiceInterface<QuestionOption, String>  {


    @Autowired
    private QuestionOptionRepository repository;

    @Autowired
    private IdWorker idWorker;


    public List<QuestionOption> findAllByQuestionId(String id) {
        return repository.findAllByQuestionId(id);
    }

    public void deleteByQuestionId(String questionId) {
        List<QuestionOption> all = findAllByQuestionId(questionId);
        for (QuestionOption option : all) {
            delete(option.getId());
        }
    }
}
